-- hp_to_attack2
-- created by chendh
-- 每损失20%的生命值时攻击百分比提升

return {
    -- 返回的是提升的攻击点数
    apply = function(prop, baseValue)
        return prop[3];
    end,

    trigger = function(who, prop, attack)
        local rate = math.modf(1000 * who:queryAttrib("hp") / who:queryAttrib("max_hp"));
        local valve = tonumber(prop[2])
        local num = math.floor((1000 - rate) / valve);

        return math.floor(attack * prop[3] * num / 1000);
    end,

    record = function(target, prop, path)
        return false;
    end
};